package com.zmz.Stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Create with IntelliT IDEA
 *
 * @Author: zhengmingzhe
 * @Date: 2022/07/31/1:23
 * @Description:  测试Stream筛选
 */
public class Stream04 {
    public static  void main(String [] args){
        List<Integer> list = Arrays.asList(7,6,8,3,2,1,4);
//        筛选大于6的数并遍历
        list.stream().filter(t->t>6).forEach(System.out::println);
        //筛选员工中工资高于8000的人
        List<Person> personList = new ArrayList<>();
        personList.add(new Person("的撒",8000,22,"女","武汉"));
        personList.add(new Person("法按时",7000,22,"女","武汉"));
        personList.add(new Person("的阿萨",7800,22,"男","武汉"));
        personList.add(new Person("答案",12000,12,"女","武汉"));
        personList.add(new Person("滴放",22000,21,"女","北京"));
        //筛选员工中工资高于8000的人
        personList.stream().filter(t->t.getSalary()>8000).forEach(System.out::println);
        System.out.println("_____");
        //筛选员工中工资高于8000的人 ,并形成集合(需要用到归集)
        List<Person> newPersonlist = personList.stream().filter(t->t.getSalary()>8000).collect(Collectors.toList());
        System.out.println(newPersonlist);
    }
}
